package com.lenovo.leos.filebrowser.netdisk;

import android.graphics.drawable.Drawable;

public class LoadedData {
	private static final String TAG = "LoadedData";
	private tag_state mstate = tag_state.ready;
	private tag_worktype mworktype =tag_worktype.download; 
	private Drawable mIcon;
	enum tag_state {
		none, ready, start, run, pause, stop, error, finish;
	}

	enum tag_type {
		dir, file
	}
	enum tag_worktype{
		download,upload,downloaddir,uploaddir
	}
	
	public LoadedData(String filename, double total, double done,
			tag_state state,tag_worktype worktype, long OpID) {
		if (null == filename || filename.length() == 0) {
			return;
		} else {
			mfilename = filename;
			mOpID = OpID;
			mtotal = total;
			mdone = done;
			mstate = state;
			mworktype = worktype;
		}
	}
	
	private double mtotal = 0;
	private double mdone = 0;
	private long mOpID = 0;
	private String mfilename = null;
	private String progress = null;
	private tag_type type = tag_type.file;
	private int persent;

	public tag_state getState() {
		return mstate;
	}

	public void setState(tag_state state) {
		this.mstate = state;
	}

	public double getTotal() {
		return mtotal;
	}

	public void setTotal(double total) {
		this.mtotal = total;
	}

	public double getDone() {
		return mdone;
	}

	public void setDone(double done) {
		this.mdone = done;
	}

	public long getmOpID() {
		return mOpID;
	}

	public void setmOpID(long mOpID) {
		this.mOpID = mOpID;
	}

	public String getMfilename() {
		return mfilename;
	}

	public void setMfilename(String mfilename) {
		this.mfilename = mfilename;
	}

	public String getProgress() {

		if (mtotal == 0) {
			mtotal = 1;
		}
		float done = (float) mdone;
		float total = (float) mtotal;
		int str = (int) ((done / total) * 100.0);

		String str1;
		str1 = str + "%";

		done = done / 1024 / 1024;
		total = total / 1024 / 1024;
		String str3 = String.valueOf(done);
		String str4 = String.valueOf(total);
		if (done != 0)
			str3 = str3.substring(0, 4);
		if (total != 0)
			str4 = str4.substring(0, 4);

		str1 = str1 + "(" + str3 + "M" + "\\" + str4 + "M" + ")";
		progress = str1;
		return progress;
	}

	public void setPersent(int persent) {
		this.persent = persent;
	}

	public int getPersent() {
		int retint = (int) ((mdone / mtotal));
		persent = retint;
		Log.i(TAG, "==>getPersent" + persent);
		return persent;
	}

	public void setProgress(String progress) {
		this.progress = progress;
	}

	public tag_type getType() {
		return type;
	}

	public void setType(tag_type type) {
		this.type = type;
	}

	public Drawable getmIcon() {
		return mIcon;
	}

	public void setmIcon(Drawable mIcon) {
		this.mIcon = mIcon;
	}
	public boolean IsDownLoad(){
		if(mworktype ==tag_worktype.download || mworktype == tag_worktype.downloaddir){
			return true;
		}else{
			return false;
		}
	}
}